package gui;

import java.awt.Point;

import flexibility.userData;
import guiCode.secretaryScreenCode;
import javax.swing.JFrame;
import javax.swing.JTable;

import basic.ClientConsole;
import secretaryGUI.createSecretaryWindow;
import com.sun.rowset.CachedRowSetImpl;
import secretaryGUI.*;
import secretary.assignStudentToCourse;
import internalMail.*;
public class secretaryScreen extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3307285392548531505L;
	createSecretaryWindow csw = new createSecretaryWindow();
	private ClientConsole secretaryConnection;
	private static secretaryScreenCode ssc;
	private userData general = new userData();
	
	updateLowerTableEntries ULTE = new updateLowerTableEntries();
	CachedRowSetImpl crs = null; // this object will hold the query results
	planNextSemester PNS = new planNextSemester();
	editCurrentSemester ECS = new editCurrentSemester();
	viewExistingClasses VEC = new viewExistingClasses();
	createNewClass CNC = new createNewClass();
	editExistingClass EEC = new editExistingClass();
	handleUpperTableEvents HUTE = new handleUpperTableEvents();
	getAllOtherStudents GAOS = new getAllOtherStudents();
	addStudentToClass ASTC = new addStudentToClass();
	removeStudentsFromClass RSFC = new removeStudentsFromClass();
	handleLowerTableEvents HLTE = new handleLowerTableEvents();
	viewCourses VC = new viewCourses();
	showClassCourses SSC = new showClassCourses();
	viewAssiginingErrorLog VAEL = new viewAssiginingErrorLog();
	assignStudentToCourse AATC = new assignStudentToCourse();
	viewAssignedClasses VAC = new viewAssignedClasses();
	viewStudents VS = new viewStudents();
	private readMail RM = new readMail();
	
	public secretaryScreen(ClientConsole conn) {
		secretaryConnection = conn;
	}
	
	public void setConnectionToCode(secretaryScreenCode codeObject){
		//this will set the code object
		ssc = codeObject;
		createGUI();
	}

	public void createGUI(){
		//this will create the gui screen;
		csw.createWindow(ssc,csw);
	}

	public void planNextSemester(){
		//this will handle plan next semester
		PNS.buttonClick(ssc, csw);
	}

	public void editCurrentSemester(){
		//this will handle plan next semester
		ECS.buttonClick(ssc, csw);
	}

	public void viewExistingClasses(){
		//this will handle plan next semester
		VEC.buttonClick(ssc, csw);
	}
	
	public void createNewClass(){
		//this will handle plan next semester
		CNC.buttonClick(ssc, csw, secretaryConnection, crs);
	}
	
	public void editExistingClass(){
		EEC.buttonClick(ssc, csw);
	}
	
	public void upperTable(Point point, int semester, int classToEdit){
		HUTE.click(ssc,csw, point, secretaryConnection, crs, semester, classToEdit);
	}
	
	public void getAllOtherStudents(int classToEdit){
		GAOS.click(ssc, csw, classToEdit, secretaryConnection, crs);
	}
	
	public void addStudentToClass(int studentID, int classID, int semester, Point point){
		ASTC.click(ssc, csw, studentID, classID, secretaryConnection, crs, semester, point);
	}
	
	public void removeStudentsFromClass(ClientConsole secretaryConnection,CachedRowSetImpl crs ){
		RSFC.click(csw, secretaryConnection, crs, ssc);
	}
	
	public void handleLowerTableEvents(Point point, int semester){
		HLTE.click(ssc, csw, point, secretaryConnection, crs, semester);
	}
	
	public void viewCourses(){
		VC.view(secretaryConnection, crs, csw, ssc);
	}
	
	public void showClassCourses(Point point, ClientConsole secretaryConnection,CachedRowSetImpl crs){
		SSC.showClassCourses(point, secretaryConnection, crs, csw, ssc);
	}
	
	public void viewAssiginingErrorLog(ClientConsole secretaryConnection,CachedRowSetImpl crs){
		VAEL.viewErrorLog(secretaryConnection, crs, ssc, csw);
	}
	
	public void assignStudentToCourse(String tableName,String courseID, int semesterReal, int classID, int automatic, int semesterID){
		AATC.assignStudentToCourse(secretaryConnection,crs, tableName, csw, courseID,  semesterReal, classID, automatic, semesterID);
	}
	
	public void viewAssignedClasses(){
		VAC.viewAssignedClasses(secretaryConnection,crs, csw, ssc);
	}
	
	public void viewStudents(){
		VS.viewStudents(secretaryConnection,crs, csw, ssc);
	}
	
	public void openMail(int userID, createMailBox cmb){
		RM.getMyMails(cmb, secretaryConnection, crs, userID);
	}
	
	public void viewTeachers(ClientConsole secretaryConnection,CachedRowSetImpl crs){
		general.deleteAll();
		general.addData(403);
		general.addData(1);
		secretaryConnection.acceptMsg(general);
		crs = secretaryConnection.getResults();
		ULTE.update(csw, crs);
	}
}
